
//Copyright 1997-2009 Syrinx Development, Inc.
//This file is part of the Syrinx Web Application Framework (SWAF).
// == BEGIN LICENSE ==
//
// Licensed under the terms of any of the following licenses at your
// choice:
//
//  - GNU General Public License Version 3 or later (the "GPL")
//    http://www.gnu.org/licenses/gpl.html
//
//  - GNU Lesser General Public License Version 3 or later (the "LGPL")
//    http://www.gnu.org/licenses/lgpl.html
//
//  - Mozilla Public License Version 1.1 or later (the "MPL")
//    http://www.mozilla.org/MPL/MPL-1.1.html
//
// == END LICENSE ==
using System;
using System.Collections;
using System.Diagnostics;

using Swaf;
using Swaf.Call;
using Swaf.Container;

namespace Swaf.BizRule
{
	public class BasicRuleInfo : IRuleInfo, ICatalogItem
	{
		protected ICall m_callInfo = null;

		protected string m_name;
		protected CallDistanceType m_distance;
		protected IDictionary m_decorators;
		protected bool m_hasStandins=false;
		protected string m_expiration=null;

		private static IDictionary s_emptyDecorators = new ReadOnlyDictionary(new Hashtable());
        private string m_searchPath = string.Empty;
        private string m_key = string.Empty;
        private string m_catalogName = string.Empty;

        public BasicRuleInfo(ICall callInfo, string name, CallDistanceType distance)
		{
			m_callInfo = callInfo;
			m_name = name;
			m_distance = distance;
		}

		public ICall CallInfo {get{return m_callInfo;}}

		#region IRuleInfo Members
		public string Expiration
		{
			get
			{
				return m_expiration;
			}
			set
			{
				m_expiration=value;
			}
		}
		public string Name
		{
			get
			{
				return m_name;
			}
		}

		public Swaf.Call.CallDistanceType CallDistance
		{
			get
			{
				return m_distance;
			}
		}

		public System.Collections.IDictionary Decorators
		{
			get
			{
				return m_decorators==null?s_emptyDecorators:m_decorators;
			}
		}

		public bool hasStandinDecorators{get{return m_hasStandins;}}

		public void addDecorator(IDecorator d)
		{
			Debug.Assert(d != null);
			if(m_decorators == null)
				m_decorators = new Hashtable();
			m_decorators[d.Name] = d;
			if(d.IsStandin)
				m_hasStandins = true;
		}



		#endregion

        public string catalogName
        {
            get { return m_catalogName; }
            set { m_catalogName = value; }
        }

        public string key
        {
            get { return m_key; }
            set { m_key = value; }
        }

        public string expiration
        {
            get { return m_expiration; }
            set { m_expiration = value; }
        }

        public string searchPath
        {
            get { return m_searchPath; }
            set { m_searchPath = value; }
        }

        public bool isCacheable
        {
            get { return true; }
        }
	}
}